﻿<my:EditableLabelBase x:Class="EditableLabel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:my="clr-namespace:Errisy"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <my:EditableLabelBase.Template>
        <ControlTemplate TargetType="{x:Type my:EditableLabelBase}">
            <Border Background="{TemplateBinding Background}">
                <Grid>
                    <TextBox Name="_TextBox" Visibility="Hidden" Text="{TemplateBinding Text}" BorderThickness="0" BorderBrush="{x:Null}" Background="{x:Null}"
                             Margin="-3,0,0,0" VerticalAlignment="Center"
                             FontFamily="{TemplateBinding FontFamily}" FontStyle="{TemplateBinding FontStyle}"
                             FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}"
                             Foreground="{TemplateBinding Foreground}"/>
                    <TextBlock Name="_Suggestion" Visibility="{TemplateBinding SuggestionVisibility}" VerticalAlignment="Center"
                               FontFamily="{TemplateBinding FontFamily}" FontStyle="{TemplateBinding FontStyle}"
                               FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}"
                               Foreground="{TemplateBinding SuggestionForeground}">
                        <Run Text="{TemplateBinding Suggestion}"/>
                    </TextBlock>
                    <TextBlock Name="_TextBlock" Visibility="Visible" VerticalAlignment="Center"
                               FontFamily="{TemplateBinding FontFamily}" FontStyle="{TemplateBinding FontStyle}"
                               FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}"
                               Foreground="{TemplateBinding Foreground}">
                        <Run Text="{TemplateBinding Text}"/>
                    </TextBlock>
                </Grid>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="IsEditing" Value="True">
                    <Setter TargetName="_TextBox" Property="Visibility" Value="Visible" />
                    <Setter TargetName="_TextBlock" Property="Visibility" Value="Hidden" />
                </Trigger>
                <Trigger Property="IsEditing" Value="False">
                    <Setter TargetName="_TextBox" Property="Visibility" Value="Hidden" />
                    <Setter TargetName="_TextBlock" Property="Visibility" Value="Visible" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </my:EditableLabelBase.Template>
</my:EditableLabelBase>
